/* jshint esversion: 6*/
let baseURL = "http://localhost:8080/OfficeAutomatic";
import $axios from 'axios';
const concatURL = url => {
    return baseURL + url + ".action";
};
const myLoginJson = paramObject => {
    let jsonString = JSON.stringify(paramObject);
    return {
        loginJson: jsonString
    };
};
const myRegisterUser = paramObject => {
    let jsonString = JSON.stringify(paramObject);
    return {
        registerUser: jsonString
    };
};
const myListParam = paramObject => {
    let jsonString = JSON.stringify(paramObject);
    return {
        listParam: jsonString
    };
};
const myUpdate = paramObject => {
    let jsonString = JSON.stringify(paramObject);
    return {
        update: jsonString
    };
};
const myDelete = paramObject => {
    let jsonString = JSON.stringify(paramObject);
    return {
        delete: jsonString
    };
};
const myInsert = paramObject => {
    let jsonString = JSON.stringify(paramObject);
    return {
        insert: jsonString
    };
};

const POST = function (url, paramObject) {
    if (paramObject == null) {
        return $axios.post(concatURL(url)).then(res => {
            return res.data;
        });
    }
    return $axios.post(concatURL(url), paramObject).then(res => {
        return res.data;
    });
};
const GET = function (url, paramObject) {
    // let jsonString = JSON.stringify(paramObject);
    if (paramObject == null) {
        return $axios.get(concatURL(url)).then(res => {
            return res.data;
        });
    }
    return $axios.get(concatURL(url), paramObject).then(res => {
        return res.data;
    });
};
export default {
    POST, GET, myLoginJson, myRegisterUser, myListParam, myUpdate, myDelete, myInsert
};